import os
os.system("nasm hello.asm -o hello.bin")
#os.system("g++ -m32 -O2 -std=c++98 -ffreestanding -fno-builtin -nostdlib -c hello.cpp -o hello.o")
#os.system("ld -m elf_i386 hello.o -o hello.o.bin -Ttext=0x30400")
sz = os.stat("hello.bin").st_size
final = open("hello.bin","ab")
#ax = open("hello.o.bin","rb")
#a = ax.read()
#final.write(a)
#sz += len(a)
while sz < 1474560:
    final.write(b'\x00')
    sz += 1
final.close()


import time

st = time.time()

while True:
    try:
        os.rename("hello.bin", "../../OS.img")
    except:
        s = f"等待虚拟机关闭...{time.time()-st:.0f}s"
        print(s, end="\b"*(len(s)+7), flush=True)
        continue
    break
